package com.hbq.codedemopersion.common.controller;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Receiver_Client {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket = new DatagramSocket(888);
        while (true) {
            byte[] buffer = new byte[1024];
            DatagramPacket packet = new DatagramPacket(buffer, 0, buffer.length);
            socket.receive(packet);
            byte[] data = packet.getData();
            String real_data = new String(data, 0, data.length);
            real_data = real_data.trim();
            if (real_data.equals("bye")) {
                break;
            }
            System.out.println(real_data);
        }
        socket.close();
    }
}